#!/usr/bin/env python

import sys, os, getopt, glob
scriptPath = os.path.realpath(os.path.dirname(sys.argv[0]))
sys.path.append(scriptPath + os.sep + 'lib')
from project import Project

def usage():
	print 'usage: toward source1 [source2..]'


def main (argv):	

	proj = Project()
	proj.destination = 'proof.rtf'

	# arguments
	
	try:
		opts, args = getopt.getopt(argv, 'o', ['output='])
	except getopt.GetoptError:
		usage()
		sys.exit(2)
		
	for opt, arg in opts:
		if (opt in ('-o', '--output')):
			proj.destination = arg

	# add source files to project	
	
	for arg in args:
		for file in glob.glob(arg):
			proj.sources.append(file)
	
	if len(proj.sources) == 0:
		print 'toward: no source files specified\n'
		sys.exit(2)
	
	# build the proof
	
	proj.proof()

	
if __name__ == '__main__':
	main(sys.argv[1:])
